﻿using System.Windows.Forms;
using DateCalculator.Library;
using System.Globalization;

namespace DateCalculator.UI.Controls
{
    /// <summary>
    /// User control to display the results of calculation in "Age/Experience" mode.
    /// </summary>
    public partial class DateCalculatorSummary : UserControl
    {
        /// <summary>
        /// Gets or sets the results.
        /// </summary>
        /// <value>The results.</value>
        public DateSpan Results { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="DateCalculatorSummary"/> class.
        /// </summary>
        public DateCalculatorSummary()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Binds data to the various child controls of this control.
        /// </summary>
        public void Bind()
        {
            YearsLabel.Text = Results.Years.ToString(CultureInfo.InvariantCulture);
            MonthsLabel.Text = Results.Months.ToString(CultureInfo.InvariantCulture);
            DaysLabel.Text = Results.Days.ToString(CultureInfo.InvariantCulture);
        }

        /// <summary>
        /// Resets the Text properties of various child controls.
        /// </summary>
        public void Reset()
        {
            YearsLabel.Text = MonthsLabel.Text = DaysLabel.Text = string.Empty;
        }

        /// <summary>
        /// Handles the Load event of the DateCalculatorSummary control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void DateCalculatorSummary_Load(object sender, System.EventArgs e)
        {
            YearsLabel.Text = MonthsLabel.Text = DaysLabel.Text = string.Empty;
        }
    }
}
